package com.dxysun.design.iterator;

public class Main
{
    public static void main(String[] args)
    {

        ConcreteAggregate<String> concreteAggregate = new ConcreteAggregate<>();
        concreteAggregate.add("a");
        concreteAggregate.add("b");
        concreteAggregate.add("c");
        concreteAggregate.add("d");

        System.out.println("遍历--------");
        print(concreteAggregate);
        System.out.println();
        System.out.println("删除后遍历--------");
        concreteAggregate.remove("c");
        print(concreteAggregate);

    }

    public static void print(ConcreteAggregate<String> concreteAggregate)
    {
        Iterator<String> iterator = concreteAggregate.iterator();
        while (iterator.hasNext())
        {
            System.out.println(iterator.next());
        }
    }
}
